#include"process.h"
#include<string.h>
#define size 101
#define style '#'
void process()
{
    int rate=0;
    char buffer[size];
    char arr[4]="|/-\\";
    memset(buffer,0,size);
    while(rate<=100)
    {
        printf("[%-100s] %d%% %c \r",buffer,rate,arr[rate%4]);
        fflush(stdout);
        buffer[rate]=style; 
        rate++;
        usleep(50000);
    }
    printf("\n");
}
void flushprocess(double total,double current)
{
    char arr[4]="|/-\\";
    static int index=0;
    double rate=current/total*100;
    int count=rate;
    char buffer[size];
    memset(buffer,0,size);
    int i=0;
    for(;i<count;i++)
        buffer[i]=style;
    printf("[%-100s] [%.1lf%%] %c\r",buffer,rate,arr[(index++)%4]);
    fflush(stdout);
}
